package com.boyi.cycling_master.https.utils;

import com.boyi.cycling_master.bean.ResponseBean;
import com.boyi.cycling_master.https.apis.APIS;

import okhttp3.RequestBody;
import okhttp3.internal.connection.RouteException;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.Body;
import retrofit2.http.POST;

/**
 * @author Lee_Mofeel
 * @version 1.0
 * @date 2017/7/28/028 13:47
 * @Description 用戶信息相关 注意这里每个接口的访问都需要包头
 */

public class UserInfoRetrofit {
    private static final UserInfoRetrofit ourInstance = new UserInfoRetrofit();
    private static Retrofit retrofit;

    public static UserInfoRetrofit getInstance() {
        retrofit = new Retrofit.Builder().baseUrl(APIS.BASE_USER_INFO_CONTROLLER_URL).addConverterFactory(GsonConverterFactory.create()).build();
        return ourInstance;
    }

    private UserInfoRetrofit() {
    }

    /* 上传头像和昵称 */
    public interface IPostNickNameAndImg {
        @POST("setHeadAndNick")
        Call<ResponseBean> toPostNickNameAndImg(@Body RequestBody body);
    }

    public void postNickNameAndImg(Callback<ResponseBean> callback, RequestBody body) {
        IPostNickNameAndImg iPostNickNameAndImg = retrofit.create(IPostNickNameAndImg.class);
        Call<ResponseBean> call = iPostNickNameAndImg.toPostNickNameAndImg(body);
        call.enqueue(callback);
    }

    /* 修改用戶信息 */
    public interface IUpdateUserInfo {
        @POST("updateUserModel")
        Call<ResponseBean> toChangeUserInfo(@Body RequestBody body);
    }

    public void changeUserInfo(Callback<ResponseBean> callback, RequestBody body) {
        IUpdateUserInfo iUpdateUserInfo = retrofit.create(IUpdateUserInfo.class);
        Call<ResponseBean> call = iUpdateUserInfo.toChangeUserInfo(body);
        call.enqueue(callback);
    }

    /* 修改用户消息机制 */
    public interface IMsgStatus {
        @POST("setMsgStatus")
        Call<ResponseBean> toChangeMsgStatus(@Body RequestBody body);
    }

    public void changeMsgStatus(Callback<ResponseBean> callback, RequestBody body) {
        IMsgStatus iMsgStatus = retrofit.create(IMsgStatus.class);
        Call<ResponseBean> call = iMsgStatus.toChangeMsgStatus(body);
        call.enqueue(callback);
    }

    /* 修改密码机制 */
    public interface IUpdatePwd {
        @POST("updateUserPwd")
        Call<ResponseBean> toChangePwd(@Body RequestBody body);
    }

    public void changePwd(Callback<ResponseBean> callback, RequestBody body) {
        IUpdatePwd iUpdate = retrofit.create(IUpdatePwd.class);
        Call<ResponseBean> call = iUpdate.toChangePwd(body);
        call.enqueue(callback);
    }

    /* 修改用户绑定手机 校验手机号 */
    public interface ICheckedPhone {
        @POST("updateBindingPhone")
        Call<ResponseBean> toCheckedPhone(@Body RequestBody body);
    }

    public void checkedPhone(Callback<ResponseBean> callback, RequestBody body) {
        ICheckedPhone iCheck = retrofit.create(ICheckedPhone.class);
        Call<ResponseBean> call = iCheck.toCheckedPhone(body);
        call.enqueue(callback);
    }

    /* 修改用户绑定手机 修改手机号 */
    public interface IChangePhone {
        @POST("updateBindingPhoneSubmit")
        Call<ResponseBean> toChangePhone(@Body RequestBody body);
    }

    public void changePhone(Callback<ResponseBean> callback, RequestBody body) {
        IChangePhone iChange = retrofit.create(IChangePhone.class);
        Call<ResponseBean> call = iChange.toChangePhone(body);
        call.enqueue(callback);
    }
    /*修改用户头像*/
    public interface IChangeUserImg{
        @POST("updateUserHead")
        Call<ResponseBean> toChangeUserHeadImg(@Body RequestBody body);
    }
    public void changeUserHeadImg(Callback<ResponseBean> callback,RequestBody body){
        IChangeUserImg iChangeUserImg = retrofit.create(IChangeUserImg.class);
        Call<ResponseBean> call = iChangeUserImg.toChangeUserHeadImg(body);
        call.enqueue(callback);
    }

    /* 提交用户反馈 */
    public interface ISubmitUserIdea{
        @POST("userFeedback")
        Call<ResponseBean> toSubmitUserIdea(@Body RequestBody body);
    }

    public void submitUserIdea(Callback<ResponseBean> callback,RequestBody body){
        ISubmitUserIdea submitUserIdea = retrofit.create(ISubmitUserIdea.class);
        Call<ResponseBean> call = submitUserIdea.toSubmitUserIdea(body);
        call.enqueue(callback);

    }


}
